# -*- coding: utf-8 -*-
# @Time : 2023/12/21 14:54
# @Author : debbyszhang
# @File : writetoexcel.py
# @desc :


import xlwt

# 创建一个新的Excel文件
workbook = xlwt.Workbook()
sheet = workbook.add_sheet('测试用例')

# # 设置第2列的宽度为10000
# col_index = 0
# width = 10000
# sheet.col(col_index).width = width

# 设置所有列的宽度为3000
width = 10000
sheet.col(0).width = width
sheet.col(1).width = width

# 写入表头
sheet.write(0, 0, '用例名称')
sheet.write(0, 1, '需求ID')
sheet.write(0, 2, '用例步骤')
sheet.write(0, 3, '预期结果')
sheet.write(0, 4, '用例类型')
sheet.write(0, 5, '用例状态')
sheet.write(0, 6, '用例等级')
sheet.write(0, 7, '创建人')
sheet.write(0, 8, '是否可自动化')
sheet.write(0, 9, '迭代版本')
sheet.write(0, 10, '脚本路径')

# 提取和写入测试用例信息
test_case_name = 'ContractManageInitContract'
requirement_id = '1014001'
test_case_steps = '111'
expected_result = '222'
test_case_type = '功能测试'
test_case_status = '正常'
test_case_priority = 'P1'
created_by = '张凤双'
is_automated = 'Python实现'
iteration_version = 'v2.3.2'
script_path = '/Users/debby/PycharmProjects/caseToTapd/writetoexcel.py'

# 写入测试用例信息到Excel文件
sheet.write(1, 0, test_case_name)
sheet.write(1, 1, requirement_id)
sheet.write(1, 2, test_case_steps)
sheet.write(1, 3, expected_result)
sheet.write(1, 4, test_case_type)
sheet.write(1, 5, test_case_status)
sheet.write(1, 6, test_case_priority)
sheet.write(1, 7, created_by)
sheet.write(1, 8, is_automated)
sheet.write(1, 9, iteration_version)
sheet.write(1, 10, script_path)

# 保存Excel文件
workbook.save('test_cases.xls')
